package user

import (
	"gitee.com/tbq_go_packages/utils"
	"github.com/savsgio/atreugo"
)

type Router struct {
	Server *atreugo.Atreugo
	cfg    *utils.Cfg
}

func (r Router) Router() {
	uc := new(UserController)
	r.Server.POST("/login", uc.Login)
	r.Server.GET("/user/create", func(ctx *atreugo.RequestCtx) error {
		db := utils.Dbconn(r.cfg)
		db.Create(&UserModel{Name: "的点点滴滴"})
		return ctx.TextResponse("func (uc UserController) Index(ctx *atreugo.RequestCtx) error {")
	})
}

func NewRouter(cfg *utils.Cfg) *Router {
	return &Router{
		Server: utils.AtreugoGetServer(cfg.GetValue("atreugo", "addr")),
		cfg:    cfg,
	}
}
